import { createBrowserRouter, Navigate } from "react-router-dom"
import LoginPage from "@/pages/Login"
import HomePage from "@/pages/Home"
import Page404 from "@/pages/Page404"
import LoadingPage from "@/pages/Loading"
import LayoutPage from "@/pages/Layout"
import RunOverviewPage from "@/pages/RunOverview"
import SysSettingPage from "@/pages/SysSetting"
import DevManagementPage from "@/pages/DevManagement"
import PlatformCommunicationPage from "@/pages/PlatformCommunication"
import HistoricalDataPage from "@/pages/HistoricalData"
import LogManagementPage from "@/pages/LogManagement"
import AlarmConfgPage from "@/pages/AlarmConfg"
import SystemInfoPage from "@/pages/SystemInfo"

const routes = [
  // 默认路由
  {
    path: "/",
    element: <Navigate to="/layout/home" replace />
  },
  // 加载页面
  {
    path: "/loading",
    name: "Loading",
    element: <LoadingPage />
  },
  // 模版页面
  {
    path: "/layout",
    name: "Layout",
    element: <LayoutPage to="/layout/home" replace />,
    children: [
      // 首页
      {
        path: "/layout/home",
        name: "Home",
        element: <HomePage />,
        meta: {
          title: "首页",
          icon: ""
        }
      },
      // 运行概览
      {
        path: "/layout/runOverview",
        name: "RunOverview",
        element: <RunOverviewPage />,
        meta: {
          title: "运行概览",
          icon: ""
        }
      },
      // 系统设置
      {
        path: "/layout/sysSetting",
        name: "SysSetting",
        element: <SysSettingPage />,
        meta: {
          title: "系统设置",
          icon: ""
        }
      },
      // 设备管理
      {
        path: "/layout/devManagement",
        name: "DevManagement",
        element: <DevManagementPage />,
        meta: {
          title: "设备管理",
          icon: ""
        }
      },
      // 平台通讯
      {
        path: "/layout/platformCommunication",
        name: "PlatformCommunication",
        element: <PlatformCommunicationPage />,
        meta: {
          title: "平台通讯",
          icon: ""
        }
      },
      // 历史数据
      {
        path: "/layout/historicalData",
        name: "HistoricalData",
        element: <HistoricalDataPage />,
        meta: {
          title: "历史数据",
          icon: ""
        }
      },
      // 日志管理
      {
        path: "/layout/logManagement",
        name: "LogManagement",
        element: <LogManagementPage />,
        meta: {
          title: "日志管理",
          icon: ""
        }
      },
      // 报警配置
      {
        path: "/layout/alarmConfg",
        name: "AlarmConfg",
        element: <AlarmConfgPage />,
        meta: {
          title: "报警管理",
          icon: ""
        }
      },
      // 系统信息
      {
        path: "/layout/systemInfo",
        name: "SystemInfo",
        element: <SystemInfoPage />,
        meta: {
          title: "系统信息",
          icon: ""
        }
      }
    ]
  },
  {
    path: "*",
    element: <Page404 />
  }
]

export default routes
